/*------------------------------------------------------------------------------
*** PURPOSE: 	The following do-file generates Figure 2 in the paper "Respondent 
				biases in household surveys" by Andrew Dillon and Edouard Romeo 
				Mensah. 

*** NOTE:		Relevant globals are defined in the do-file titles "master.do"
				contained in the folder "02_do" in the replication package.
------------------------------------------------------------------------------*/	
	
	
	* Figure 2. Number of daily visits to complete the whole questionnaire.
	
	
	tabstat nvisits_full, by(treatarm)
	reg nvisits_full i.treatarm
	
/*
    treatarm |      mean
-------------+----------
     Control |  1.806916
     HH head |  1.771014
Random proxy |  1.520833
-------------+----------
       Total |  1.701362
------------------------
-------------------------------------------------------------------------------
 nvisits_full |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
     treatarm |
     HH head  |  -.0359019   .1022748    -0.35   0.726    -.2365938      .16479
Random proxy  |  -.2860831   .1029594    -2.78   0.006    -.4881183   -.0840479
              |
        _cons |   1.806916   .0722146    25.02   0.000     1.665211    1.948622
-------------------------------------------------------------------------------
*/	
	
	cibar nvisits_full, over1(treatarm) ///
	graphopts(legend(order(1 "Self-report" 2 "Household head" 3 "Random proxy")) ///
	xtitle("Survey design group") ytitle("Mean number of visits") ///
	title("") name(nvisitfull, replace))
	
	tabstat nvisits_full if treatarm==2, by(resp_female)
	reg nvisits_full i.resp_female if treatarm==2
	
/*
resp_female |      mean
------------+----------
          0 |  1.584906
          1 |  1.439252
------------+----------
      Total |   1.53605
-----------------------
-------------------------------------------------------------------------------
 nvisits_full |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
1.resp_female |  -.1456533    .139684    -1.04   0.298    -.4204783    .1291716
        _cons |   1.584906    .080899    19.59   0.000     1.425739    1.744073
-------------------------------------------------------------------------------
*/
	
	cibar nvisits_full if treatarm==2, over1(resp_female) ///
	graphopts(legend(order(1 "Male" 2 "Female")) ///
	xtitle("Gender of the random proxy respondent") ytitle("Mean number of visits") ///
	title("") name(nvisitrp, replace))
	
	graph combine nvisitfull nvisitrp, ycommon /// 
	title("Number of daily visits to complete the whole questionnaire") ///
	subtitle("Mean and 95% confidence interval")
	graph save "04_output\Figure 2. Number of daily visits to complete the whole questionnaire.gph", replace
	
	